#ifndef __MSP_UART_H__
#define __MSP_UART_H__

#ifdef __cplusplus
extern "C" {
#endif

/* Includes ------------------------------------------------------------------*/
#include <stdint.h>

#define UART2_USE_DMA                       0                                       // 串口2为debug串口，仅测试串口时使用DMA

#define UART1_RX_BUFFER_SIZE                (512+128)
#define UART1_TX_BUFFER_SIZE                (512+128)
#if UART2_USE_DMA
#define UART2_RX_BUFFER_SIZE                (0+128)
#define UART2_TX_BUFFER_SIZE                (0+128)
#endif
#define UART4_RX_BUFFER_SIZE                (512+128)
#define UART4_TX_BUFFER_SIZE                (512+128)

// // 未用到
// #define UART1_RX_DMA_CHANNEL                DMA1_CHANNEL6
// #define UART1_RX_DMA_IRQN                   DMA1_Channel6_IRQn
// #define UART1_RX_DMA_BUFFER_DMA_SIZE        256
// #define UART1_RX_DMA_BUFFER_FIFO_SIZE       2048
// // 未用到
// #define UART2_RX_DMA_CHANNEL                DMA1_CHANNEL4
// #define UART2_RX_DMA_IRQN                   DMA1_Channel4_IRQn
// #define UART2_RX_DMA_BUFFER_DMA_SIZE        256
// #define UART2_RX_DMA_BUFFER_FIFO_SIZE       2048
// // 未用到
// #define UART4_RX_DMA_CHANNEL                DMA1_CHANNEL3
// #define UART4_RX_DMA_IRQN                   DMA1_Channel3_IRQn
// #define UART4_RX_DMA_BUFFER_DMA_SIZE        256
// #define UART4_RX_DMA_BUFFER_FIFO_SIZE       2048

// extern uint8_t uart4_rx_buffer_dma[UART4_RX_DMA_BUFFER_DMA_SIZE];

void MSP_Usart1_Init(uint32_t baud_rate);
void MSP_Usart2_Init(uint32_t baud_rate);

// void USART1_SendData(const uint8_t *data, uint16_t size);
void USART2_SendData(const uint8_t *data, uint16_t size);

#if UART2_USE_DMA
uint8_t Msp_Uart2_Write(uint8_t *pdata, uint16_t len);
uint16_t MSP_Uart2_Read(uint8_t *pdata);
#endif

#if UART2_USE_DMA
void Msp_Uart2_Write_Dma_Callback(void);
void MSP_Uart2_Read_Uart_Callback(void);
#endif

#ifdef __cplusplus
}
#endif

#endif /* __MSP_UART_H__ */

